home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / VGADOC4B.ZIP / SUPERVGA.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-09-29  |  66.6 KB  |  2,128 lines

  1. unit supervga;
  2.  
  3. interface
  4. uses dos,crt;
  5.  
  6.  
  7.  
  8. {$i defvga.pas}   {Definitions}
  9.  
  10.  
  11. {$i bitblt.pas}
  12.  
  13. var
  14.   curbank:word;   {The current bank number. Set by SetBank}
  15.   vgran:word;
  16.  
  17.  
  18.   {Sets the Bank registers in units of 64Kbytes. If the chip has separate
  19.    Read/Write Bank registers, both are set}
  20. procedure setbank(bank:word);
  21. var x:word;
  22.     l:longint;
  23. begin
  24.   if bank=curbank then exit;   {Only set bank if diff. from current value}
  25.   vseg:=SegA000;
  26.   curbank:=bank;
  27.   case cv.chip of
  28.       __Acer:begin      {Read/Write banks or 32K banks?}
  29.                wrinx(GRC,$10,bank);
  30.                wrinx(GRC,$11,bank);
  31.              end;
  32.      __ahead:if cv.version=AH_B then wrinx(GRC,13,bank*17)
  33.              else begin
  34.            wrinx(GRC,13,bank shr 1);
  35.            x:=inp($3cc) and $df;
  36.            if odd(bank) then inc(x,32);
  37.            outp($3c2,x);
  38.          end;
  39.        __ALG:begin
  40.            outp($3d7,bank);
  41.            outp($3D6,bank);
  42.          end;
  43.       __Alli:begin
  44.                if mem[SegA000:$D8]=0 then;
  45.                outpw(SEQ,$1210);
  46.                setinx(SEQ,$1C,8);
  47.                modinx(SEQ,$1B,7,1);
  48.                memw[SegA000:$C0]:=bank shl 4;
  49.                clrinx(SEQ,$1B,7);
  50.                clrinx(SEQ,$1C,8);
  51.              end;
  52.        __ARK:begin
  53.                wrinx(SEQ,$15,bank);
  54.                wrinx(SEQ,$16,bank);
  55.              end;
  56.     __Mach32:begin
  57.            x:=(bank and 15)*$22;          {Roll bank nbr into bit 0}
  58.            wrinx(cv.IOadr,$B2,hi(x) or lo(x));
  59.            modinx(cv.IOadr,$AE,$F,(bank shr 4)*5);
  60.          end;
  61.     __Mach64:begin
  62.                bank:=bank*2;
  63.                outp($56EC,bank);
  64.                outp($56EE,bank+1);
  65.                outp($5AEC,bank);
  66.                outp($56EE,bank+1);
  67.              end;
  68.        __ati:begin
  69.            if cv.version=ATI_18800 then
  70.          modinx(cv.IOadr,$B2,$1E,bank shl 1)
  71.            else begin
  72.          x:=(bank and 15)*$22;          {Roll bank nbr into bit 0}
  73.          wrinx(cv.IOadr,$B2,hi(x) or lo(x));
  74.            end;
  75.            if cv.version>=ATI_GUP_3 then
  76.          modinx(cv.IOadr,$AE,$F,(bank shr 4)*5);
  77.          end;
  78.      __chips:if (cv.version<=CT_457) then wrinx(cv.IOadr,$B,bank)
  79.          else begin
  80.            if memmode<=_pl4 then bank:=bank shl 2;
  81.            if cv.version<>CT_452 then bank:=bank shl 2;
  82.            wrinx(cv.IOadr,$10,bank shl 2);
  83.                if cv.Version=CT_64300 then
  84.                  modinx(cv.IOadr,$C,$10,bank shr 2);
  85.          end;
  86.      __cir54:begin
  87.            if (rdinx(GRC,$B) and 32)=0 then bank:=bank shl 2;
  88.            wrinx(GRC,9,bank shl 2);
  89.          end;
  90.      __cir64:begin
  91.            bank:=bank shl 4;
  92.            wrinx(GRC,$E,bank);
  93.            wrinx(GRC,$F,bank);
  94.          end;
  95.     __compaq:begin
  96.            wrinx(GRC,$F,5);
  97.            bank:=bank shl 1;
  98.                if (cv.Version>=CPQ_QV1024) and
  99.                  ((inp($23C7) and $10)>0) then x:=1
  100.                                           else x:=3;
  101.                if (cv.version=CPQ_AVGA) and (memmode=_PL4) then x:=5;
  102.            wrinx(GRC,$45,bank shl x);
  103.            if (rdinx(GRC,$40) and 1)>0 then inc(bank);
  104.            wrinx(GRC,$46,(bank) shl x);
  105.          end;
  106.     __everex:begin
  107.            x:=inp($3CC) and $DF;
  108.            if (bank and 2)>0 then inc(x,32);
  109.            outp($3C2,x);
  110.            modinx(SEQ,8,$80,bank shl 7);
  111.          end;
  112.      __genoa:wrinx(SEQ,6,bank*9+$40);
  113.        __HMC:begin
  114.            if memmode=_p8 then modinx(SEQ,$EE,$70,bank shl 4)
  115.            else if bank=0 then vseg:=SegA000 else vseg:=SegB000;
  116.          end;
  117.     __Matrox:begin
  118.                if memmode<=_pl4 then bank:=bank*4;
  119.                modinx($3DE,9,$F,bank);
  120.              end;
  121.       __mxic:wrinx(SEQ,$c5,bank*17);
  122.        __ncr:begin
  123.            if memmode<=_pl4 then bank:=bank shl 2;
  124.            wrinx(SEQ,$18,bank shl 2);
  125.            wrinx(SEQ,$1C,bank shl 2);
  126.          end;
  127.        __oak:if cv.Version<=OAK_083 then wrinx($3DE,$11,bank*17)
  128.              else begin
  129.            wrinx($3DE,$23,bank);
  130.            wrinx($3DE,$24,bank);
  131.          end;
  132.         __WD:begin
  133.            wrinx(GRC,9,bank shl 4);
  134.            wrinx(GRC,$A,bank shl 4);
  135.            if cv.version=WD_90c33 then
  136.          modinx(SEQ,$14,$C0,((bank shr 4) and 1)*$C0);
  137.          end;
  138.      __p2000,
  139.    __realtek:begin
  140.            outp($3d6,bank);
  141.            outp($3d7,bank);
  142.          end;
  143.     __s3:begin
  144.            if memmode<=_pl4 then bank:=bank*4;
  145.                wrinx(crtc,$39,$A5);
  146.                if cv.Version>=S3_864 then wrinx(crtc,$6A,bank)
  147.                else begin
  148.              wrinx(crtc,$38,$48);
  149.              setinx(crtc,$31,9);
  150.                  modinx(crtc,$35,$F,bank);
  151.                  if cv.version>S3_924 then modinx(crtc,$51,$C,bank shr 2);
  152.                  wrinx(crtc,$38,0);
  153.                end;
  154.                wrinx(crtc,$39,$5A);
  155.          end;
  156.         __SC:begin
  157.                outp($3CD,bank shl 1);
  158.                wrinx(SEQ,$15,bank shl 1);
  159.              end;
  160.        __SiS:begin
  161.                outp($3CD,bank);
  162.                outp($3CB,bank);
  163.              end;
  164.      __Poach,
  165.       __trid:if cv.version=TR_8800BR then
  166.              begin
  167.                modinx(SEQ,$E,6,bank);
  168.                if (bank and 1)>0 then vseg:=SegB000 else vseg:=SegA000;
  169.              end
  170.              else if cv.Version>=TR_9000C then
  171.              begin
  172.                outp($3D8,bank);
  173.                outp($3D9,bank);
  174.              end
  175.              else begin
  176.                wrinx(SEQ,$B,0);
  177.                if rdinx(SEQ,$B)=0 then;  {New mode}
  178.                if (memmode<=_pl4) and (bank>1) then inc(bank,2);
  179.                modinx(SEQ,$E,$F,bank xor 2);
  180.          end;
  181.      __Tseng:if cv.Version=ET_3000 then outp($3CD,bank*9+$40)
  182.          else begin
  183.            outp($3CD,(bank and 15)*17);
  184.            if cv.version<>ET_4000 then
  185.          outp($3CB,(bank shr 4)*17);
  186.          end;
  187.     __video7:if cv.Version<V7_208A then
  188.          begin
  189.            if memmode>_pl4 then
  190.            begin
  191.          x:=inp($3CC) and $DF;
  192.          if (bank and 2)>0 then inc(x,32);
  193.          outp($3C2,x);
  194.          modinx(SEQ,$F9,1,bank);
  195.          bank:=bank shr 2;
  196.            end;
  197.            modinx(SEQ,$F6,$F,bank*5);
  198.          end
  199.          else begin
  200.                if memmode<=_PL4 then bank:=bank*4;
  201.            wrinx(SEQ,$E8,bank shl 4);
  202.           { wrinx(SEQ,$E9,bank shl 4+8); {Don't work ?}
  203.          end;
  204.        __UMC:wrinx(SEQ,6,bank*17);
  205.     __Weitek:outp($3CD,bank*17);
  206.       __vesa:begin
  207.            rp.bx:=0;
  208.            bank:=bank*longint(64) div vgran;
  209.            rp.dx:=bank;
  210.            vio($4f05);
  211.            rp.bx:=1;
  212.            rp.dx:=bank;
  213.            vio($4f05);
  214.          end;
  215.        __AGX,__xbe,__xga:
  216.              outp(cv.IOadr+8,bank);
  217.   __WeitekP9:outp($3CD,bank or $20);  {Actually only the W5x86 Vipers}
  218.   end;
  219. end;
  220.  
  221.   {Sets the Read Bank register in units of 64Kbytes}
  222. procedure setRbank(bank:word);
  223. var x:word;
  224. begin
  225.   curbank:=$FFFF;    {always flush}
  226.   case cv.chip of
  227.     __ahead:if cv.version=AH_B then modinx(GRC,$D,$F,bank);
  228.       __ALG:outp($3D6,bank);
  229.     __Mach32:begin
  230.           x:=(bank and $F) shl 5;
  231.           modinx(cv.IOadr,$B2,$E1,hi(x) or lo(x));
  232.           modinx(cv.IOadr,$AE,$C,bank shr 2);
  233.         end;
  234.    __Mach64:begin
  235.               bank:=bank shl 1;
  236.               mem[cv.Xseg:$B8]:=bank;
  237.               mem[cv.Xseg:$BA]:=bank+1;
  238.             end;
  239.       __ARK:wrinx(SEQ,$16,bank);
  240.       __ati:begin                {Roll bank nbr into bit 0}
  241.           x:=(bank and $F) shl 5;
  242.           modinx(cv.IOadr,$B2,$E1,hi(x) or lo(x));
  243.           if cv.version>=ATI_GUP_3 then
  244.         modinx(cv.IOadr,$AE,$C,bank shr 2);
  245.         end;
  246.     __cir64:wrinx(GRC,$E,bank shl 4);
  247.     __Genoa:modinx(SEQ,6,7,bank);
  248.      __mxic:modinx(SEQ,$C5,$F0,bank shl 4);
  249.       __ncr:begin
  250.            if memmode<=_pl4 then bank:=bank shl 2;
  251.            wrinx(SEQ,$1C,bank shl 2);
  252.         end;
  253.       __oak:if cv.Version<=OAK_083 then modinx($3DE,$11,$F,bank)
  254.                                    else wrinx($3DE,$23,bank);
  255.        __WD:begin
  256.           wrinx(GRC,9,bank shl 4);
  257.           if cv.version=WD_90c33 then
  258.         modinx(SEQ,$14,$40,bank shl 2);
  259.         end;
  260.     __p2000:outp($3D7,bank);
  261.   __realtek:outp($3D6,bank);
  262.       __SiS:outp($3CB,bank);
  263.      __Trid:if cv.Version>=TR_9000C then outp($3D9,bank);
  264.  
  265.     __Tseng:if cv.Version=ET_3000 then modreg($3CD,$38,bank shl 3)
  266.         else begin
  267.           modreg($3CD,$F0,bank shl 4);
  268.           if cv.version<>ET_4000 then
  269.         modreg($3CB,$30,bank);
  270.         end;
  271.  {  __Video7:if cv.Version>=V7_208A then wrinx(SEQ,$E9,(bank shl 4)+8); }
  272.       __UMC:modinx(SEQ,6,$F,bank);
  273.    __Weitek:modreg($3CD,$F0,bank shl 4);
  274.   end;
  275. end;
  276.  
  277.  
  278. procedure vesamodeinfo(md:word;var vbedata);
  279. const
  280.   width :array[$100..$11b] of word=
  281.       (640,640,800,800,1024,1024,1280,1280,80,132,132,132,132
  282.       ,320,320,320,640,640,640,800,800,800,1024,1024,1024,1280,1280,1280);
  283.   height:array[$100..$11b] of word=
  284.       (400,480,600,600, 768, 768,1024,1024,60, 25, 43, 50, 60
  285.       ,200,200,200,480,480,480,600,600,600, 768, 768, 768,1024,1024,1024);
  286.   bits  :array[$100..$11b] of byte=
  287.       (  8,  8,  4,  8,   4,   8,   4,   8, 0,  0,  0,  0,  0
  288.       , 15, 16, 24, 15, 16, 24, 15, 16, 24,  15,  16,  24,  15,  16,  24);
  289.  
  290.   swidth :array[0..$13] of word=
  291.      ( 40, 40, 80, 80,320,320,640, 80,0,0,0,0,0,320,640,640,640,640,640,320);
  292.   sheight:array[0..$13] of word=
  293.      ( 25, 25, 25, 25,200,200,200, 25,0,0,0,0,0,200,200,350,350,480,480,200);
  294.   sbytes :array[0..$13] of word=
  295.      ( 80, 80,160,160, 80, 80, 80,160,0,0,0,0,0, 40, 80, 80, 80, 80, 80,320);
  296.   sbits  :array[0..$13] of byte=
  297.      (  1,  4,  1,  4,  2,  2,  1,  1,0,0,0,0,0,  4,  4,  1,  4,  1,  4,  8);
  298.   smode  :array[0..$13] of byte=
  299.      (  0,  0,  0,  0,  1,  1,  1,  0,0,0,0,0,0,  3,  3,  3,  3,  3,  3,  4);
  300.  
  301. var
  302.   vbxx:_vbe1;
  303.   vbe1:^_vbe1;
  304. begin
  305.   if @vbedata=NIL then vbe1:=@vbxx
  306.                   else vbe1:=@vbedata;
  307.   fillchar(vbe1^,sizeof(_vbe1),0);
  308.   viop($4f01,0,md,0,vbe1);
  309.   if rp.ax=$4F then
  310.   begin
  311.     if ((vbe1^.attr and 2)=0) then
  312.       if (md>=$100) and (md<=$11b) then  { optional info missing }
  313.       begin
  314.         vbe1^.width :=width[md];
  315.         vbe1^.height:=height[md];
  316.         vbe1^.bits  :=bits[md];
  317.       end;
  318.  
  319.     if (md>=0) and (md<=$13) then  {Standard VGA modes - Many VESAs screw
  320.                                     up these modes, so always force them!!}
  321.     begin
  322.       vbe1^.width :=swidth[md];
  323.       vbe1^.height:=sheight[md];
  324.       vbe1^.bytes :=sbytes[md];
  325.       vbe1^.bits  :=sbits[md];
  326.       vbe1^.model :=smode[md];
  327.       vbe1^.gran:=64;
  328.     end;
  329.  
  330.     vgran :=vbe1^.gran;
  331.     bytes :=vbe1^.bytes;
  332.     pixels:=vbe1^.width;
  333.     lins  :=vbe1^.height;
  334.   end;
  335. end;
  336.  
  337.  
  338. procedure initxga;
  339. var xbe1:_xbe1;
  340.   x:word;
  341. begin
  342.   outp(cv.IOAdr+1,1);     {64K aperture at A000h}
  343.   clrreg(cv.IOadr+9,8);   {Intel pixel format}
  344.  
  345.   x:=(bytes*8) div usebits[memmode];
  346.  
  347.   if pixels=1280 then setinx(cv.IOadr+10,$6D,$C);
  348.  
  349.   mem [cv.xseg:$12]:=1;
  350.   meml[cv.xseg:$14]:=cv.phadr;
  351.   memw[cv.xseg:$18]:=x-1;
  352.   memw[cv.xseg:$1A]:=lins-1;
  353.   case memmode of
  354.    _pk4:x:=2;
  355.     _p8:x:=3;
  356.    _p16:x:=4;
  357.    _p24:x:=5;  {Only AGX?}
  358.   end;
  359.   mem [cv.xseg:$1C]:=x;
  360.   meml[cv.xseg:$50]:=$FFFFFF;  {Enable all planes}
  361.   meml[cv.xseg:$54]:=$FFFFFF;  {Enable all carry planes}
  362. end;
  363.  
  364. function safemode(md:word):boolean;
  365. var x,y:word;
  366. begin                 {Checks if we entered a Graph. mode}
  367.   safemode:=false;
  368.   wrinx(crtc,$11,0);
  369.   wrinx(crtc,1,0);
  370.   vio(lo(md));
  371.   if (rdinx(crtc,1)<>0) or (rdinx(crtc,$11)<>0) then
  372.   begin
  373.     if (md<=$13) or (mem[Seg0040:$49]<>3) then safemode:=true;
  374.   end;
  375. end;
  376.  
  377. procedure setdacpal(r,g,b:word);
  378. begin
  379.   outp($3C9,r);
  380.   outp($3C9,g);
  381.   outp($3C9,b);
  382. end;
  383.  
  384. function tsvio(ax,bx:word):boolean;   {Tseng 4000 Hicolor mode set}
  385. begin
  386.   rp.bx:=bx;
  387.   vio(ax);
  388.   tsvio:=(rp.ax=16);
  389. end;
  390.  
  391.   {ATI mode set}
  392. function setATImode(md:word):boolean;
  393. begin
  394.   rp.bx:=$5506;
  395.   rp.bp:=$ffff;
  396.   rp.si:=0;
  397.   vio($1200+md);
  398.   if rp.bp=$ffff then setATImode:=safemode(md)  {Try normal modeset}
  399.   else begin
  400.     vio(md);
  401.     setATImode:=true;
  402.   end;
  403. end;
  404.  
  405. procedure SetRGBPal(inx,r,g,b:word);
  406. var i,j:word;
  407. begin
  408.   if inp($3C6)=0 then;  {delay}
  409.   outp(setDACpage(dacSTDwrInx),inx);
  410.   if inp($3C6)=0 then;  {delay}
  411.   inx:=setDACpage(dacSTDpelData);
  412.   if inp($3C6)=0 then;
  413.   outp(inx,r);
  414.   if inp($3C6)=0 then;
  415.   outp(inx,g);
  416.   if inp($3C6)=0 then;
  417.   outp(inx,b);
  418.   clearDACpage;
  419. end;
  420.  
  421.  
  422.   {Halfs all the Horizontal CRTC timings (3d4h index 0/5)}
  423. procedure HalfCRTC;
  424. var r0,r1,r2,r3,r4,r5,old:integer;
  425. begin
  426.   old:=rdinx(crtc,$11);
  427.   clrinx(crtc,$11,$80);
  428.   r0:=rdinx(crtc,0)+5;
  429.   r1:=rdinx(crtc,1)+1;
  430.   r2:=rdinx(crtc,2);
  431.   r3:=rdinx(crtc,3) and $1F;
  432.   r4:=rdinx(crtc,4);
  433.   r5:=rdinx(crtc,5) and $1F;
  434.   if (rdinx(crtc,5) and $80)>0 then inc(r3,$20);
  435.   r3:=(r2 and $FFC0)+r3;
  436.   if r3<=r2 then inc(r3,$40);
  437.   r5:=(r4 and $FFE0)+r5;
  438.   if r5<=r4 then inc(r5,$20);
  439.  
  440.   r0:=r0 div 2;
  441.   r1:=r1 div 2;
  442.   r2:=r2 div 2;
  443.   r3:=r3 div 2;
  444.   r4:=r4 div 2;
  445.   r5:=r5 div 2;
  446.   if r3>=r0-1 then dec(r3);
  447.   wrinx (crtc,0,r0-5);
  448.   wrinx (crtc,1,r1-1);
  449.   wrinx (crtc,2,r2);
  450.   modinx(crtc,3,$1F,r3);
  451.   wrinx (crtc,4,r4);
  452.   modinx(crtc,5,$1F,r5);
  453.   modinx(crtc,5,$80,r3 shl 2);
  454.   wrinx(crtc,$11,old);
  455. end;
  456.  
  457. const
  458.   MachActive:boolean=false;
  459. var
  460.   tst:word;
  461.  
  462. function SetMode(md:word;clear:boolean):boolean;
  463. const
  464.   Red:  array[0..15] of byte=(0, 0, 0, 0,42,42,42,42,21,21,21,21,63,63,63,63);
  465.   Green:array[0..15] of byte=(0, 0,42,42, 0, 0,21,42,21,21,63,63,21,21,63,63);
  466.   Blue: array[0..15] of byte=(0,42, 0,42, 0,42, 0,42,21,63,21,63,21,63,21,63);
  467.  
  468. var x,y,prt:word;
  469.   l2,l:longint;
  470.   vbe1:_vbe1;
  471. begin
  472.   setmode:=true;
  473.   dacHWcursor:=((cv.features and ft_cursor)=0) and ((DACflags and DFL_Cursor)>0);
  474.   curmode:=md;
  475.   if ((cv.flags and FLG_StdVGA)>0) and (md<=$13) then
  476.     for x:=1 to novgamodes do
  477.       if stdmodetbl[x].md=md then
  478.       begin
  479.         memmode:=stdmodetbl[x].memmode;
  480.         bytes  :=stdmodetbl[x].bytes;
  481.         pixels :=stdmodetbl[x].xres;
  482.         lins   :=stdmodetbl[x].yres;
  483.       end;
  484.  
  485.   case cv.chip of
  486.     __ati:begin
  487.                 clrinx(cv.IOadr,$B3,$40);   {Mach64 doesn't clear this}
  488.                 setmode:=setATImode(md);
  489.               end;
  490.      __Mach32:begin
  491.                 cv.IOadr:=$1CE;
  492.                 if MachActive then
  493.                 begin
  494.                   outp($42EE,0);
  495.                     {mov ax,0 call c000h:64h  mov al,0  call C000h:68h}
  496.               inline($B8/>0/$9A/>$64/>SegC000/$B0/0/$9A/>$68/>SegC000);
  497.                   MachActive:=false;
  498.                   clrinx(cv.IOadr,$B6,1);
  499.                   clrinx(cv.IOadr,$BE,8);
  500.                 end;
  501.         if md>=$100 then
  502.         begin
  503.           {mov ax,[BP+md]  mov bx,1  call C000h:64h  mov al,1  call C000h:68h}
  504.           inline($8B/$46/<md/$BB/>1/$9A/>$64/>SegC000/$B0/1/$9A/>$68/>SegC000);
  505.           setmode:=true;
  506.  
  507.                   case memmode of
  508.                    _pk4b:bytes:=((pixels+127) and $FF80) div 2;
  509.               _p8:bytes:=(bytes+127) and $FF80;
  510.                _p15,_p16:bytes:=((pixels+127) and $FF80)*2;
  511.                     _p24:bytes:=((pixels+127) and $FF80)*3;
  512.                   end;
  513.           outp($5EEE,inp($5EEE) and $FC);   {Disable Memory Aperture}
  514.                   outp($42EE,0);
  515.                   inline($B8/>$62/$CD/$10);
  516.                   setinx(cv.IOadr,$B6,1);
  517.                   setinx(cv.IOadr,$BE,8);
  518.                   MachActive:=true;
  519.         end
  520.         else setmode:=safemode(md);
  521.           end;
  522.      __Mach64:begin
  523.                 if MachActive then
  524.                 begin
  525.                   vio($100);
  526.                     {mov al,1  mov cl,0  CALL C000h:64h}
  527.                   inline($B0/0/$B1/1/$9A/>$64/>SegC000);
  528.                   MachActive:=false;
  529.                 end;
  530.  
  531.                   {mov al,0  mov cx,[BP+md]  CALL C000h:64h}
  532.                 inline($B0/0/$8B/$4E/<md/$9A/>$64/>SegC000);
  533.                 VIO($E2);     {Set VGA mode}
  534.                 setreg($6AEC,4);
  535.                   {mov al,1  mov cl,1  CALL C000h:64h}
  536.                 inline($B0/1/$B1/1/$9A/>$64/>SegC000);
  537.                 MachActive:=true;
  538.                 setmode:=true;
  539.                 case colbits[memmode] of
  540.                   15:setmode:=setdac15;
  541.                   16:setmode:=setdac16;
  542.                   24:if memmode>=_P32 then setmode:=setdac32
  543.                                       else setmode:=setdac24;
  544.                 else setmode:=true;
  545.                 end;
  546.               end;
  547.      __compaq:begin
  548.         setmode:=safemode(md);      {HM, what a hack}
  549.         if memmode=_p16 then setmode:=setdac16;
  550.                  {outp($13C8,$38); {Force 64Kcolors}
  551.           end;
  552.      __everex:begin
  553.         rp.bl:=md;
  554.         vio($70);
  555.           end;
  556.      __Matrox:if (md>$13) then
  557.               begin
  558.                 vio($BD00+md);
  559.                 if rp.ax<>-1 then setmode:=true;
  560.               end
  561.               else setmode:=safemode(md);
  562.         __oak:if safemode(md) then
  563.         case memmode of
  564.           _p15:setmode:=setdac15;
  565.           _p16:setmode:=setdac16;
  566.           _p24:setmode:=setdac24;   {Hm}
  567.         end
  568.           else setmode:=false;
  569.      __s3:if md<$100 then setmode:=safemode(md)
  570.           else begin
  571.         rp.bx:=md;
  572.         vio($4f02);
  573.         if rp.ax=$4f then
  574.         begin
  575.           if md<$200 then vesamodeinfo(md,vbe1);
  576.           if (memmode=_p16) and setdac16 then;
  577.         end
  578.         else begin
  579.           setmode:=false;
  580.           dac2comm;
  581.           outp($3C6,0);
  582.           dac2pel;
  583.         end;
  584.           end;
  585.     __AGX,__Poach,
  586.        __trid:if cv.version>=TR_GUI9420 then setmode:=safemode(md)
  587.               else begin
  588.         vio(md);
  589.         if (rp.ah>=$80) then setmode:=false;
  590.                 if (cv.version=TR_9000i) then
  591.             case memmode of   {9000i doesn't set HiColor modes}
  592.             _p15:if not setdac15 then setmode:=false;
  593.             _p16:if not setdac16 then setmode:=false;
  594.           end;
  595.           end;
  596.       __Tseng:case hi(md) of
  597.         0:setmode:=safemode(md);
  598.         1:if tsvio($10E0,lo(md)) then
  599.           begin
  600.             {Diamond SpeedStar 24 does not clear memory}
  601.             for x:=0 to 15 do         {clear memory}
  602.             begin
  603.               setbank(x);
  604.               mem[SegA000:0]:=0;
  605.               fillchar(mem[SegA000:1],65535,0);
  606.             end;
  607.           end else setmode:=false;
  608.         2:if tsvio($10f0,md shl 8+$ff) then
  609.           begin
  610.             if bytes=2048 then
  611.             begin         {Bug correction for the MEGAVGA BIOS}
  612.               outp($3bf,3);
  613.               outp(crtc+4,$a0);   {enable Tseng 4000 Extensions}
  614.               wrinx(crtc,$13,0);
  615.               setinx(crtc,$3f,$80);
  616.             end
  617.           end else setmode:=false;
  618.         3:if tsvio($10F0,lo(md)) and setdac15 then
  619.  
  620.           else setmode:=false;
  621.         4:if tsvio($10F0,lo(md)) and setdac16 then
  622.           else setmode:=false;
  623.         5:if not tsvio($10f0,md) then setmode:=false;
  624.           end;
  625.      __video7:begin
  626.         rp.bl:=md;
  627.         vio($6f05);
  628.           end;
  629.        __vesa:begin
  630.                 vesamodeinfo(md,vbe1);
  631.         rp.bx:=md;
  632.         vio($4f02);
  633.         if rp.ax<>$4f then setmode:=false
  634.         else begin
  635.          { vesamodeinfo(md,NIL);}
  636.           cv.chip:=__vesa;
  637.         end;
  638.           end;
  639.     __UMC:begin
  640.                 outp($3BF,$AC);
  641.                 case memmode of
  642.                   _p15:clrinx(GRC,$A,4);
  643.                   _p16:setinx(GRC,$A,4);
  644.                 end;
  645.  
  646.         setmode:=safemode(md);
  647.                 if cv.version=UMC_408 then
  648.                 case memmode of
  649.                     _p15:setmode:=setdac15;
  650.                     _p16:setmode:=setdac16;
  651.                   end;
  652.                 if md=$51 then clrinx(SEQ,9,$80);
  653.           end;
  654.          __WD:if (md=$13) and (cv.version=WD_90c33) then
  655.               begin
  656.                 vio($5E);
  657.                 clrinx(GRC,$E,1);
  658.                 wrinx(crtc,$13,40);   {320 bytes/linbe}
  659.                 setinx(crtc,9,1);     {Double line}
  660.               end
  661.               else setmode:=safemode(md);
  662.     __xbe:begin
  663.         viop($4E03,md,0,cv.id,NIL);
  664.         if rp.ax<>$4E then setmode:=false;
  665.           end;
  666.   else setmode:=safemode(md);
  667.   end;
  668.  
  669.   if (inp($3CC) and 1)=0 then crtc:=$3B4 else crtc:=$3D4;  {Mono/Color}
  670.   case colbits[memmode] of
  671.     8:begin
  672.         if dacis8bit then prt:=4 else prt:=1;
  673.         for x:=0 to 63 do
  674.         begin
  675.           y:=x*prt;
  676.           SetRGBPal(x    ,y,0,0);    {  0- 63: Red}
  677.           SetRGBPal(x+64 ,0,y,0);    { 64-127: Green}
  678.           SetRGBPal(x+128,0,0,y);    {128-191: Blue}
  679.           SetRGBPal(x+192,y,y,y);    {192-255: White}
  680.         end;
  681.         SetRGBPal(0,0,0,0);  {Some cards screw up the first palette entry}
  682.       end;
  683.     4:for x:=0 to 15 do
  684.       begin
  685.         SetRGBPal(x,Red[x],Green[x],Blue[x]);
  686.         if (cv.flags and FLG_StdVGA)>0 then wrinx($3C0,x,x);
  687.       end;
  688.   end;
  689.   case (rdinx(GRC,6) shr 2) and 3 of
  690.     0,1:vseg:=SegA000;
  691.       2:vseg:=SegB000;
  692.       3:vseg:=SegB800;
  693.   end;
  694.  
  695.  
  696.    { Enable banks...  }
  697.  
  698.  { if memmode>_CGA2 then}
  699.   case cv.chip of
  700.     __AGX:if memmode>=_PL4 then
  701.           begin
  702.         modinx(GRC,6,$C,4);
  703.         cv.spcreg:=$1E0-(((rdinx(cv.IOadr+10,$75) and 7)-1) shl 4);
  704.                 initxga;
  705.           end;
  706.       __ahead:begin
  707.         setinx(GRC,$F,$20);
  708.         if (memmode>_cga2) {and (md<>$13)} then setinx(GRC,$C,$20);
  709.                 if md=$13 then
  710.                 begin
  711.                   HalfCRTC;
  712.                   wrinx(crtc,$13,20);
  713.                   setinx(GRC,$E,1);    {Switches from clock 8 (50.35MHz) to
  714.                                         clock 12 (25.175MHz) - pure luck!!!}
  715.                   clrinx($3C0,$10,$40);
  716.                 end;
  717.           end;
  718.     __ALG:begin
  719.         setinx(crtc,$1A,$10);    {Enable extensions}
  720.         setinx(crtc,$19,2);      {Enable >256K}
  721.         setinx(GRC,$F,4);        {Enable RWbank}
  722.           end;
  723.        __Alli:begin
  724.                 wrinx(SEQ,$10,$12);
  725.                 clrinx(SEQ,$1C,$F);
  726.               end;
  727.         __ARK:begin
  728.                 setinx(SEQ,$1D,1);    {Enable extensions}
  729.                 clrinx(crtc,$31,1);   {256K wrap}
  730.                 clrinx(crtc,$43,8);
  731.                 case colbits[memmode] of
  732.                   15,16:x:= 8;
  733.                   24,32:x:=12;
  734.                 else    x:= 4;
  735.                 end;
  736.                 modinx(SEQ,$11,$C,x);
  737.                 case pixels of
  738.                   800:x:=1;
  739.                  1024:x:=2;
  740.                  1280:x:=4;
  741.                 else x:=0;
  742.                 end;
  743.                 modinx(SEQ,$17,7,x);
  744.                 setinx(SEQ,$10,3);    {Enable all of Vmem}
  745.               end;
  746.     __ati:if memmode>_CGA2 then
  747.               begin
  748.                 if cv.version>=ATI_M64_GX then
  749.                 begin
  750.                   setinx(cv.IOadr,$B0,8);
  751.                   clrreg($6AEC,7);
  752.                 end;
  753.         if cv.version>=ATI_28800_4 then
  754.           setinx(cv.IOadr,$B6,1);    {enable display >256K}
  755.                 if cv.version>=ATI_18800_1 then
  756.                   clrinx(cv.IOadr,$B3,$10);  {enable display >256K}
  757.                 if (cv.Version>=ATI_18800_1) {and (cv.version<ATI_GUP_3)} then
  758.                 begin
  759.                   if ((rdinx(cv.IOadr,$B6) and $10)=0) and ((memmode=_pl4)
  760.                     or (md=$13)) then
  761.                   begin
  762.                     if md=$13 then  {Fix mode 13h}
  763.                     begin
  764.                       setinx(crtc,$17,$40);
  765.                       clrinx(crtc,$14,$40);
  766.                       clrinx(GRC,5,$40);
  767.                       clrinx($3C0,$10,$40);
  768.                       setinx(SEQ,1,8);
  769.                       if (cv.version=ATI_18800_1) then
  770.                       begin
  771.                         setinx(cv.IOadr,$B0,$30);
  772.                       end
  773.                       else begin
  774.                         setinx(cv.IOadr,$B0,$20);
  775.                         setinx(cv.IOadr,$B6,4);   {Linear addressing}
  776.                       end;
  777.                     end
  778.                     else begin {16color modes (planar)}
  779.                       setinx(cv.IOadr,$B3,$40);
  780.                       setinx(cv.IOadr,$B6,$18);
  781.                     end;
  782.                     HalfCRTC;
  783.                     wrinx(crtc,$13,rdinx(crtc,$13) div 2);
  784.                     if (md=$D) and (cv.version<ATI_M64_GX) then {Mode 0Dh - Arghh}
  785.                     begin
  786.                       clrinx(SEQ,1,8);    {Switch from /4 to /3 - Arghh}
  787.                       modinx(cv.IOadr,$B8,$C0,$80);  {--}
  788.                       clrinx(crtc,$11,$80);  {Allow CRTC reprogramming}
  789.                       wrinx(crtc,0,$19);
  790.                       wrinx(crtc,3,$96);     {Reprogram Horizontal Timing}
  791.                       wrinx(crtc,4,$17);
  792.                     end;
  793.                   end;
  794.                 end;
  795.         if cv.version>ATI_18800 then
  796.           setinx(cv.IOAdr,$BE,8);    {enable RWbanks}
  797.           end;
  798.       __chips:begin
  799.         if cv.version<CT_450 then
  800.         begin
  801.           prt:=$46E8;
  802.           x:=inp(prt);
  803.           outp(prt,x or $10);     {setup mode}
  804.           y:=inp($103);
  805.           outp($103,y or $80);    {Enable extensions}
  806.           outp(prt,x and $EF);
  807.           if (y and $40)=0 then cv.IOadr:=$3D6 else cv.IOadr:=$3B6;
  808.         end
  809.                 else cv.IOadr:=$3D6;
  810.         wrinx(cv.IOadr,$15,0);  {No write protection}
  811.                 clrinx(cv.IOadr,$14,1); {This bit, if set needs explicit clearing}
  812.                 setinx(cv.IOadr,$B,1);  {Enable banks}
  813.         if memmode>_cga2 then
  814.         begin
  815.           setinx(cv.IOadr,4,4);  {Enable bank access}
  816.           case cv.version of
  817.             CT_450,CT_452,CT_453:
  818.             begin
  819.               modinx(cv.IOadr,$B,3,1);
  820.               clrinx(cv.IOadr,$C,3);
  821.             end;
  822.             CT_65510,CT_65520,CT_65530:
  823.             begin
  824.               setinx(cv.IOadr,4,8);
  825.               modinx(cv.IOadr,$B,3,1);
  826.               clrinx(cv.IOadr,$C,3);
  827.             end;
  828.                CT_64300:clrinx(cv.IOadr,$B,$10);
  829.           end;
  830.           if md=$13 then
  831.           begin
  832.             setinx(cv.IOadr,$B,4);   {By 4 addressing}
  833.             setinx(crtc,$17,$40);
  834.             clrinx(crtc,$14,$40);
  835.           end;
  836.         end;
  837.           end;
  838.       __cir54:begin
  839.         wrinx(SEQ,6,$12);    {Enable Extensions}
  840.         setinx(crtc,$1B,2);      {Enable mem >256K}
  841.         if cv.mm>1024 then
  842.         begin
  843.           setinx(GRC,11,$20);    {Set 16K banks}
  844.           setinx(SEQ,$f,$80);    {Enable Ext mem}
  845.         end;
  846.                 if md=$13 then
  847.                 begin
  848.                   setinx(SEQ,7,1);      {Extended Graph mode}
  849.                   setinx(SEQ,1,8);      {Half VClk rate =12.6MHz}
  850.                   {setinx(crtc,$1B,$20);} {Blanking Ctl ??}
  851.  
  852.                   HalfCRTC;
  853.                 end;
  854.                 if (cv.Version>=CL_GD5426) and (memmode>_pl4)
  855.                   and (md<>$13) then    {Init BitBlt engine}
  856.                 begin
  857.                   wrinx2(GRC,$24,bytes);
  858.                   wrinx2(GRC,$26,bytes);
  859.                   case memmode of
  860.              _p15,_p16:x:=$10;
  861.                   _P32:x:=$30;    {543x only}
  862.                   else x:=0;
  863.                   end;
  864.                   wrinx(GRC,$30,x);
  865.                   setbank(cv.mm div 64-1);   {Setup Mono image for Fill}
  866.                   meml[SegA000:$FFF8]:=$FFFFFFFF;  {Fill Pattern}
  867.                   meml[SegA000:$FFFC]:=$FFFFFFFF;
  868.                 end;
  869.           end;
  870.       __cir64:begin
  871.         wrinx(GRC,$A,$EC);       {Enable extensions}
  872.         if memmode>_cga2 then setinx(GRC,$D,7);
  873.           end;
  874.      __compaq:begin
  875.         modinx(GRC,$F,$F,5);  {Enable extensions}
  876.         setinx(GRC,$10,8);
  877.                 if memmode>=_PL4 then
  878.                 begin
  879.                   if rdinx(GRC,$F)<>$A5 then
  880.                   begin
  881.                     setreg($23C7,$10);
  882.                     if pixels>1024 then
  883.                     begin
  884.                       modreg($63CB,$C,8);
  885.                       bytes:=256*usebits[memmode];
  886.                     end
  887.                     else if pixels>512 then
  888.                     begin
  889.                       modreg($63CB,$C,4);
  890.                       bytes:=128*usebits[memmode];
  891.                     end
  892.                     else begin
  893.                       modreg($63CB,$C,0);
  894.                       bytes:=64*usebits[memmode];
  895.                     end;
  896.                     wrinx(crtc,$13,bytes shr 3);
  897.                     modinx(GRC,$42,3,bytes shr 11);
  898.                   end;
  899.                   if ((md<>$13) or (cv.version=CPQ_AVGA))
  900.                     and (memmode>=_P8) then setinx(GRC,$40,$1);
  901.                   dacHWcursor:=(DACflags and DFL_cursor)>0;
  902.                 end;
  903.           end;
  904.       __Genoa:begin
  905.         setinx(SEQ,8,$40);    {Ext Addressing}
  906.         setinx(SEQ,$10,4);    {RWbank}
  907.           end;
  908.     __HMC:if memmode>=_cga2 then
  909.           begin
  910.         if memmode=_pl4 then
  911.         begin
  912.           setinx(SEQ,$E7,$4);
  913.           clrinx(GRC,6,$C);
  914.         end;
  915.                 if (memmode=_P8) and ((rdinx(SEQ,$E7) and 2)=0) then
  916.                 begin   {Fix mode 13h}
  917.                   HalfCrtc;
  918.                   setinx(SEQ,$E7,2);
  919.                   clrinx(GRC,5,$40);
  920.                   clrinx($3C0,$10,$40);
  921.                   setinx(SEQ,1,8);
  922.                 end;
  923.                  end;
  924.      __Mach32:begin
  925.                 outpw($DAEE,0);     {Clipping}
  926.                 outpw($E2EE,2047);
  927.                 outpw($DEEE,0);
  928.                 outpw($E6EE,2047);
  929.                 outpw($6EEE,0);     {GE Offset}
  930.                 outpw($72EE,0);
  931.                 outpw($EEEE,0);     {Disable Color Compare}
  932.                 outpw($AAE8,$FFFF); {Write Mask}
  933.                 tst:=inpw($8EEE);
  934.               end;
  935.      __Mach64:begin
  936.                 modreg($6AEC,7,4);
  937.                 mem[cv.Xseg:$C5]:=(mem[cv.Xseg:$C5] and $DF); {non-VGA DAC}
  938.                 setreg($4EEE,$A0);  {Reset GUI engine}
  939.                 outpw($66EC,0);
  940.                 outpw($66EC,$100);
  941.  
  942.                 write32($338,0);  {GUI_STAT (needed for PCI)}
  943.                 write32($310,0);  {FIFO_STAT}
  944.  
  945.                 outp($4EEE,$FF);    {BUS_CNTL: Clear FIFO errors}
  946.  
  947.                 outpl($66EC,0);
  948.                 outpl($66EC,$100);
  949.  
  950.                 repeat until memw[cv.Xseg:$310]=0;
  951.                 case usebits[memmode] of
  952.                    4:l:=$10101;
  953.                    8:l:=$20202;
  954.                   15:l:=$30303;
  955.                   16:l:=$40404;
  956.                   24:l:=$50505;   {Hm?}
  957.                   32:l:=$60606;
  958.                 end;
  959.                 write32($2D0,l);           {Pixel Width}
  960.                 write32($320,$FFFFFFFF);   {Context MAsk}
  961.                 write32($108,0);
  962.                 write32($118,0);
  963.                 write32($124,0);
  964.                 write32($128,0);
  965.                 write32($12C,0);
  966.                 write32($130,3);
  967.  
  968.                 write32($18C,0);   {Src Y_X}
  969.                 write32($198,0);
  970.                 write32($1A4,0);
  971.                 write32($1B0,0);
  972.                 write32($1B4,0);
  973.  
  974.                 repeat until memw[cv.Xseg:$310]=0;
  975.                 write32($240,0);
  976.                 write32($280,0);
  977.                 write32($284,0);
  978.                 write32($288,0);
  979.                 write32w($2A8,pixels-1,0);  {Clip left/right}
  980.                 write32w($2B4,lins-1,0);    {Clip top/bot}
  981.                 write32($2C0,0);
  982.                 write32($2C4,0);
  983.                 write32($2C8,$FFFFFFFF);   {Write mask}
  984.                 write32($2D4,$70003);      {DP_MIX}
  985.                 write32($2D8,$100);        {Source}
  986.  
  987.                 write32($300,0);
  988.                 write32($304,$FFFFFFFF);   {Color Cmp Mask}
  989.                 write32($308,0);           {Color Cmp off}
  990.                 write32($330,3);           {GUI trajetory}
  991.  
  992.                 repeat until memw[cv.Xseg:$310]=0;
  993.                 l:=longint(pixels shr 3) shl 22;
  994.                 write32($100,l);    {Dest Offset & pitch}
  995.                 write32($180,l);
  996.                 repeat until (mem[cv.Xseg:$338] and 1)=0;
  997.               end;
  998.      __Matrox:begin
  999.                 if md=$13 then   {The mode is redefined, but with a 62kHz Hsync!}
  1000.                 begin
  1001.                   setinx($3DE,1,9);   {Ext 256color & enable banks}
  1002.                   HalfCRTC;
  1003.                   wrinx(crtc,$13,20);
  1004.                 end;
  1005.               end;
  1006.        __mxic:begin
  1007.         setinx(SEQ,$65,$40);
  1008.         wrinx(SEQ,$A7,$87);    {enable extensions}
  1009.         setinx(SEQ,$C3,4);     {Enable banks}
  1010.         setinx(SEQ,$F0,8);     {Enable display >256k}
  1011.           end;
  1012.     __ncr:begin
  1013.         wrinx(SEQ,5,1);
  1014.         wrinx(SEQ,$18,0);
  1015.         wrinx(SEQ,$19,0);
  1016.         wrinx(SEQ,$1C,0);
  1017.         wrinx(SEQ,$1D,0);
  1018.         setinx(SEQ,$1E,$1C);
  1019.                 if cv.version<NCR_77c32blt then
  1020.                 begin
  1021.                   wrinx(SEQ,5,5);
  1022.                   wrinx(SEQ,$1A,0);
  1023.                   wrinx(SEQ,$1B,0);
  1024.                 end;
  1025.                 if md=$13 then
  1026.                 begin
  1027.                   setinx(SEQ,$20,2);
  1028.                   setinx(SEQ,$21,1);
  1029.                   clrinx(GRC,5,$40);
  1030.                   clrinx(SEQ,4,8);
  1031.                   clrinx($3C0,$10,$40);
  1032.                   setinx(crtc,$17,$40);
  1033.                   clrinx(crtc,$14,$40);
  1034.                   setinx(SEQ,$1F,$10);
  1035.                   setinx(SEQ,1,8);
  1036.                 end;
  1037.                 if (cv.version=NCR_77c32BLT) and (memmode>=_PL4) then
  1038.                 begin
  1039.                   wrinx3(SEQ,$31,$0b00);
  1040.                   setinx(SEQ,$30,1);      {ACM at BFF0:0}
  1041.                   case memmode of
  1042.                     _P15,_P16:x:=$10;
  1043.                    _P24,_P24b:x:=$20;
  1044.                   else x:=0;
  1045.                   end;
  1046.                   modinx(SEQ,$21,$30,x);  {Pixel Width}
  1047.                   cv.Xseg:=SegB000;
  1048.                 end;
  1049.           end;
  1050.     __oak:if cv.version<>OAK_037 then
  1051.               begin
  1052.         if (memmode>=_pl4) and (cv.mm>256) then
  1053.                 begin
  1054.                   if (md<>$13) and (cv.Version<=OAK_083) then setinx($3DE,$D,$C);
  1055.                   if (memmode=_pl4) then setinx($3DE,$D,$10);
  1056.                 end;
  1057.            { if md=$13 then
  1058.         begin
  1059.           wrinx(crtc,$14,0);
  1060.           wrinx(crtc,$13,20);
  1061.           wrinx(crtc,$17,$c3);
  1062.           setinx($3DE,$21,5);
  1063.                   HalfCRTC;
  1064.         end;  Creates a 320x200 mode without 64K limitations
  1065.             however there is no pixel doubling, creating a
  1066.             "double screen"  }
  1067.           end;
  1068.          __WD:begin
  1069.         modinx(GRC,$F,$17,5); {Enable extensions PR0-4}
  1070.         wrinx(crtc,$29,$85);  {Enable extensions 2}
  1071.         wrinx(SEQ,6,$48);     {Enable extended sequencers}
  1072.         clrinx(GRC,$B,8);
  1073.         if (md<>$13) or (cv.version<>WD_90c33) then clrinx(crtc,$2F,2);
  1074.                 clrinx(crtc,$2F,$78);
  1075.         setinx(SEQ,$11,$80);  {enable dual bank}
  1076.                 if (cv.Version=WD_90c33) and (memmode>=_pl4) then
  1077.                 begin
  1078.                 {  while (inpw($23CE) and $F)>0 do; }
  1079.                   outpw($23C0,3);    {Drw Eng Bank 2}
  1080.                   outpw($23C2,0);           {Map BAse}
  1081.                   outpw($23C2,$1000+pixels); {Row Pitch}
  1082.                   outpw($23C2,$AFFF);       {Enable all planes}
  1083.                   outpw($23C2,$BFFF);
  1084.                   outpw($23C0,1);        {Drw Eng Bank 1}
  1085.                   case memmode of
  1086.                      _pl4:outpw($23C2,$1000);
  1087.                       _p8:outpw($23C2,$1400);
  1088.                 _p15,_p16:outpw($23C2,$1800);
  1089.                   end;
  1090.                   outpw($23C2,$9000);
  1091.                   outpw($23C2,$A000+pixels);
  1092.                   outpw($23C2,$B000);
  1093.                   outpw($23C2,$C000+lins);      {Set Clip}
  1094.                   outpw($23CE,$20);
  1095.                   while (inpw($23CE) and $F)>0 do;
  1096.                   outpw($23C2,0);
  1097.  
  1098.                 end;
  1099.           end;
  1100.       __p2000:begin
  1101.         if memmode=_p16 then
  1102.         begin
  1103.           dac2comm;
  1104.           outp($3C6,$C0);
  1105.         end;
  1106.           end;
  1107.     __realtek:begin
  1108.         if memmode>=_pl1 then setinx(crtc,$19,$A2);   {display from upper 512k}
  1109.            { setinx(GRC,$C,32); }
  1110.         setinx(GRC,$F,4);       {dual bank}
  1111.           end;
  1112.      __s3:if memmode>_CGA2 then
  1113.           begin
  1114.                 if cv.Version<S3_864 then S3accelOff;
  1115.         wrinx(crtc,$38,$48);
  1116.         wrinx(crtc,$39,$A5);
  1117.         modinx(crtc,$31,$39,9);   {Enable access >256K & banking}
  1118.                 wrinx(crtc,$4E,0);    {zero cursor offset}
  1119.                 wrinx(crtc,$4F,0);
  1120.         clrinx(crtc,$45,$3D);     {Cursor type}
  1121.  
  1122.                 if bytes=800 then  {800x600 P8 appears busted in acc.}
  1123.                 begin              {modes on the STB Pegasus, so fixit..}
  1124.                   bytes:=1024;
  1125.                   wrinx(crtc,$13,128);
  1126.                 end;
  1127.         if cv.version>S3_924 then
  1128.         begin
  1129.            clrinx(crtc,$55,$30);     {Force MS-Windows cursor & int. DAC}
  1130.                   case memmode of
  1131.          _p15,_p16:begin
  1132.                              if cv.version<S3_864 then
  1133.                    setinx(crtc,$45,4);  {16bit cursor pixels}
  1134.                  x:=$10;
  1135.                end;
  1136.          _p24,_p32:begin
  1137.                              if cv.version<S3_864 then
  1138.                    setinx(crtc,$45,8)   {32bit cursor pixels}
  1139.                  else
  1140.                                setinx(crtc,$45,4);  {16bit cursor pixels}
  1141.                  x:=$30;
  1142.                end;
  1143.                   else x:=0;
  1144.           end;
  1145.                   case (bytes*8) div usebits[memmode] of
  1146.                     640:x:=x+$40;
  1147.                     800:x:=x+$80;
  1148.                    1280:x:=x+$C0;
  1149.                    1152:x:=x+$01;   {1152/1600 do not work on 801/5 A/B & 928 A-D}
  1150.                    1600:x:=x+$81;
  1151.                   end;
  1152.                   modinx(crtc,$50,$F1,x);     {8bpp & 640/800/1024/1280 pixels/line}
  1153.                   if ((rdinx(crtc,$55) and 8)>0)
  1154.                    or ((cv.version>=S3_864) and ((rdinx(crtc,$65) and 2)>0)) then
  1155.                   begin                   {Piping VRAM directly to the DAC,
  1156.                                          internal cursor will NOT work}
  1157.                     dacHWcursor:=true;
  1158.                     setinx(crtc,$45,$20);    {Ext DAC Ctrl enable}
  1159.                     setinx(crtc,$55,$20);    {Enable Ext HW cur}
  1160.                   end;
  1161.                 end;
  1162.                 clrinx(crtc,$34,$80);     {allow Clock change}
  1163.         wrinx(crtc,$39,$5A);
  1164.         wrinx(crtc,$38,0);
  1165.           end;
  1166.         __SiS:begin
  1167.                 outpw(SEQ,$8605);
  1168.                 setinx(SEQ,$B,8);   {Set 3CDh as Write bank, 3CBh as read}
  1169.                 if memmode>_CGA2 then setinx(SEQ,6,2);  {Enable banks}
  1170.                 if md=$13 then
  1171.                 begin
  1172.                   clrinx($3C0,$10,$40);
  1173.                   setinx(SEQ,1,8);
  1174.                   HalfCRTC;
  1175.                 end;
  1176.               end;
  1177.       __Poach,
  1178.        __trid:if memmode>_CGA2 then
  1179.           begin
  1180.         setinx(crtc,$1E,$80);   { Enable 17bit display start }
  1181.         if (cv.Version=TR_8900C) or (cv.version>=TR_9000C) then
  1182.                 begin
  1183.                   if (cv.mm>512) then
  1184.           begin
  1185.             wrinx(SEQ,$B,0);
  1186.             x:=inp(SEQ+1);    {Switch to new mode}
  1187.             x:=rdinx(SEQ,$E);
  1188.             wrinx(SEQ,$E,$80);
  1189.             setinx(SEQ,$C,$20);
  1190.             wrinx(SEQ,$E,x);
  1191.                   end;
  1192.           if cv.version<>TR_8900C then
  1193.             setinx(GRC,$F,5);  {Enable ?? & Read/Write}
  1194.         end;
  1195.         if cv.version<>TR_8800BR then modinx(GRC,6,$C,4);
  1196.                 if cv.version>=TR_GUI9440 then
  1197.                    wrinx(crtc,$36,$82);
  1198.           end;
  1199.       __Tseng:begin
  1200.                 outp($3BF,3);
  1201.                 outp(crtc+4,$A0);
  1202.                 case cv.version of
  1203.           ET_3000:begin
  1204.             setinx(SEQ,4,2);
  1205.                         if (((md=$13) or (memmode=_PL4)) and (md<>$D)
  1206.                           and ((rdinx(SEQ,7) and $40)=0)) then
  1207.                         begin
  1208.                           HalfCRTC;
  1209.               wrinx(crtc,$13,rdinx(crtc,$13) div 2);
  1210.                           if md=$13 then
  1211.                           begin
  1212.                             clrinx(crtc,$14,$40);
  1213.                             clrinx(SEQ,4,8);
  1214.                             wrinx(crtc,$17,$C3);
  1215.                           end
  1216.                           else for x:=0 to 15 do wrinx($3C0,x,x);
  1217.               setinx($3C0,$16,$10);
  1218.               clrinx(crtc,$11,$80);
  1219.               setinx(SEQ,7,$40);
  1220.                         end;
  1221.               end;
  1222.           ET_4000:if (cv.dactype=_dacMU1880) and (memmode=_p24) then memmode:=_P24b;
  1223.             else if memmode>=_pl4 then
  1224.                 begin  {W32 series}
  1225.           setinx(crtc,$36,$28);   {Enables MMU registers}
  1226.           if vseg=SegA000 then cv.Xseg:=SegB800  {setup accelerator MMU}
  1227.                       else cv.Xseg:=SegA800;
  1228.                           {The 32K at either A800 or B800 is divided into
  1229.                            4 ranges: Offset 7F00h-7FFFh holds the memory
  1230.                            mapped registers, 4000h-5FFFh is controlled by MMU2
  1231.                            and is used to transfer CPU data, 2000h-3FFFh is
  1232.                            controlled by MMU1 and holds the Pattern data }
  1233.                   mem [cv.xseg:$7F30]:=0;
  1234.                   mem [cv.xseg:$7F30]:=$10;
  1235.                   while (mem [cv.xseg:$7F36] and 2)>0 do;
  1236.                   mem [cv.xseg:$7F30]:=0;
  1237.  
  1238.           mem [cv.xseg:$7F35]:=$E; {clear Interrupts}
  1239.           memw[cv.xseg:$7F34]:=$0; {Disable Interrupts}
  1240.           mem [cv.xseg:$7F36]:=0;
  1241.           mem [cv.xseg:$7F9D]:=0;    {Reload Off}
  1242.           mem [cv.xseg:$7F32]:=1;    {Wait for Queue'd register to clear}
  1243.  
  1244.                   if cv.Version>=ET_4W32p_a then
  1245.                   begin
  1246.                     mem[cv.xseg:$7F8E]:=0;  {Pixel Depth - 8bit}
  1247.                     mem[cv.xseg:$7F31]:=$10;  {Startup}
  1248.                   end
  1249.                   else begin
  1250.                     write32($7F94,0);
  1251.                     {meml[cv.xseg:$7F94]:=0; {Reset X,Y position}
  1252.                     mem [cv.xseg:$7F31]:=0;
  1253.                   end;
  1254.                   l:=cv.mm*longint(1024)-8 {4};
  1255.  
  1256.                   write32($7F00,l);
  1257.                   write32($7F80,l);
  1258.                   {meml[cv.xseg:$7F00]:=l;    {Adr of pattern in Vmem}
  1259.                      {Had some trouble with two word writes failing to update
  1260.                       the full longword, thus the move() -> rep movsb}
  1261.                   l:=meml[cv.xseg:$7F00];
  1262.                   write32($7F08,0);
  1263.               {meml[cv.xseg:$7F08]:=0;   {Start of Video Memory}
  1264.                mem [cv.xseg:$7F13]:=4;   {MM1 -> pattern (color), MM2 -> 0}
  1265.                   memw[cv.xseg:$7F88]:=3;         {Pattern Pitch}
  1266.                   memw[cv.xseg:$7F8A]:=bytes-1;         {Source Pitch}
  1267.                   memw[cv.xseg:$7F8C]:=bytes-1;         {Dest Width}
  1268.                mem [cv.xseg:$7F90]:=$12;               {4byte x 1line pattern}
  1269.                mem [cv.xseg:$7F92]:=$77;             {Source don't wrap}
  1270.             end;
  1271.                 end;
  1272.               end;
  1273.     __umc:begin
  1274.         OUTP($3BF,$AC);     {Enable extensions}
  1275.         setinx(SEQ,8,$80);    {Enable banks bit0}
  1276.         clrinx(crtc,$2F,$2);  {Enable >256K}
  1277.           end;
  1278.      __video7:begin
  1279.         wrinx(SEQ,6,$EA);    {Enable extensions}
  1280.                 if memmode>=_pl4 then
  1281.                 begin
  1282.                   setinx(SEQ,$F6,$C0);  {prevent display wrap}
  1283.             if memmode>=_P8 then modinx(SEQ,$FC,6,4); {Enable 256c banks}
  1284.                   if (cv.version>=V7_216BC) and (memmode=_P8)
  1285.                     and ((rdinx(GRC,5) and $40)>0) then
  1286.                   begin     {Force all 256c modes to Ext 256c}
  1287.                     clrinx(GRC,5,$40);
  1288.                     setinx(SEQ,$C8,$10);
  1289.                     modinx($3C0,$10,$C0,$80);
  1290.                     setinx(SEQ,1,8);
  1291.                     HalfCRTC;
  1292.                   end;
  1293.  
  1294.                   {if cv.Version>=V7_208A then
  1295.                    setinx(SEQ,$E0,$80);  {Enable Dual bank }
  1296.                   if cv.version>=V7_208A then
  1297.              setinx(SEQ,$FF,$10);   {Enable banks & memory>256K}
  1298.                 end;
  1299.           end;
  1300.      __Weitek:begin
  1301.         x:=WeitekEnable(0);
  1302.           end;
  1303.   __xbe,__xga:initxga;
  1304.   end;
  1305.   curbank:=$ffff;    {Set curbank invalid }
  1306.   planes:=1;
  1307.   setinx(SEQ,4,2);    {Set "more than 64K" flag}
  1308.  
  1309.   setvstart(0,0);   {Reset start of display}
  1310.   case memmode of
  1311.   _text,_txt2,_txt4,
  1312.   _pl1e,_pl2:planes:=2;
  1313.     _pl4:planes:=4;
  1314.   end;
  1315.   if clear and (vseg=SegA000) then
  1316.   begin
  1317.     l:=(cv.mm*longint(1024)-256) shr 1;    {#Words to clear}
  1318.     x:=0;                  {Leave a few bytes at the end for patterns etc}
  1319.     while (l>0) do
  1320.     begin
  1321.       setbank(x); inc(x);
  1322.       y:=32768;
  1323.       if l<y then y:=l;
  1324.       dec(l,y);
  1325.         {cld  mov cx,[BP+y]  mov ax,0A000  mov es,ax  xor ax,ax  xor di,di  rep stosw}
  1326.       inline($FC/$8B/$4E/<y/$B8/>SegA000/$8E/$C0/$31/$C0/$31/$FF/$F3/$AB);
  1327.     end;
  1328.   end;
  1329.   AnalyseMode;
  1330. end;
  1331.  
  1332.  
  1333. procedure SetTextMode;
  1334. begin
  1335.   case cv.chip of
  1336.       __ATI:clrinx(cv.IOadr,$B3,$40);   {Mach64 doesn't clear this}
  1337.  
  1338.    __Mach32:if MachActive then
  1339.             begin
  1340.               outp($42EE,0);
  1341.               {mov ax,0 call c000h:64h  mov al,0  call C000h:68h}
  1342.           inline($B8/>0/$9A/>$64/>$C000/$B0/0/$9A/>$68/>SegC000);
  1343.               MachActive:=false;
  1344.               clrinx(cv.IOadr,$B6,1);
  1345.               clrinx(cv.IOadr,$BE,8);
  1346.             end;
  1347.   end;
  1348.  
  1349.   clearDACpage;
  1350.   if (DACflags and DFL_CmdReg)>0 then
  1351.   begin
  1352.     dac2comm;     {Reset DAC}
  1353.     outp($3c6,0);
  1354.     dac2pel;
  1355.   end;
  1356.   if setmode(3,false) then;
  1357.   textmode($103);
  1358. end;
  1359.  
  1360.  
  1361. {const
  1362.   set15:array[0..13] of byte=(0,0,$A0,$A0,$A0,$A0,$C1,0,$80,$F0,$A0,0,0,0);
  1363.   msk15:array[0..13] of byte=(0,0,$80,$C0,$FF,$E0,$C7,0,$C0,$FF,$E0,0,0,0);
  1364.  
  1365.   set16:array[0..13] of byte=(0,0,  0,$E0,$A6,$C0,$C5,0,$C0,$E1,$C0,0,0,0);
  1366.   msk16:array[0..13] of byte=(0,0,  0,$C0,$FF,$E0,$C7,0,$C0,$FF,$E0,0,0,0);
  1367.  
  1368.   set24:array[0..13] of byte=(0,0,  0,  0,$9E,$E0,$80,0,$60,$E5,$E0,0,0,0);
  1369.   msk24:array[0..13] of byte=(0,0,  0,  0,$FF,$E0,$C7,0,$E0,$FF,$E0,0,0,0); }
  1370.  
  1371.  
  1372.  
  1373. var
  1374.   dacpath:integer;
  1375.  
  1376. procedure GetDACpath;
  1377. begin
  1378.   dacpath:=8;
  1379.   case cv.chip of
  1380.      __ARK:if (cv.version>=ARK_2000PV) and ((rdinx(crtc,$46) and 4)>0) then dacpath:=16;
  1381.       __SC:if (rdinx(GRC,$C) and 3)=3 then dacpath:=16;
  1382.    __Tseng:if (cv.version>=ET_4000) and ((rdinx($3C0,$16) and $20)>0) then dacpath:=16;
  1383.   end;
  1384. end;
  1385.  
  1386.  
  1387. function prepDAC:word;     {Sets DAC up to receive command word}
  1388. var x:word;
  1389. begin
  1390.  { dac2comm; }
  1391.   {if cv.dactype=_dacss24 then
  1392.   begin
  1393.     dac2comm;
  1394.     x:=8;
  1395.     while (x>0) and (daccomm<>$8E) do
  1396.     begin
  1397.       daccomm:=inp($3C6);
  1398.       dec(x);
  1399.     end;
  1400.     prepDAC:=daccomm;
  1401.   end
  1402.   else} begin
  1403.     prepDAC:=getdaccomm{inp($3C6)};
  1404.     dac2comm;
  1405.   end;
  1406. end;
  1407.  
  1408. procedure dacmode(andmsk,ormsk:word);
  1409. var x,pel:word;
  1410. begin
  1411.   ormsk:=ormsk and (not andmsk);
  1412.  { if cv.DAC_RS2<>0 then
  1413.   begin
  1414.     outp($3C6+cv.DAC_RS2,(inp($3C6+cv.DAC_RS2) and andmsk) or ormsk);
  1415.   end
  1416.   else} begin
  1417.     if cv.chip=__cir54 then
  1418.     begin
  1419.       pel:=inp($3C6);
  1420.       outp($3C6,0);
  1421.     end;
  1422.     x:=getdaccomm{prepDAC};
  1423.     dac2comm;
  1424.     outp($3C6,(x and andmsk) or ormsk);
  1425.     dac2pel;
  1426.     if cv.chip=__cir54 then outp($3C6,pel);
  1427.  
  1428.   end;
  1429. end;
  1430.  
  1431.  
  1432.  
  1433. procedure setBt1DAC(mode:word);
  1434. begin
  1435. {  dac2comm;
  1436.   outp($3C6,mode);
  1437.   dac2pel;}
  1438.   outp(setDACpage(dacBt1cmdA),mode);
  1439.  { dacmode(0,mode);}
  1440. end;
  1441.  
  1442. procedure setSTGdac(mode:word);
  1443. var m:word;
  1444. begin
  1445.   m:=inp(SetDACpage(dacHIcmd));
  1446.   outp(SetDACpage(dacHIcmd),m or 16);
  1447.   dac2comm;
  1448.   m:=inp($3C6);
  1449.   outp($3C6,3);
  1450.   outp($3C6,0);
  1451.   outp($3C6,mode);
  1452.   outp($3C6,mode);
  1453.   outp($3C6,2);
  1454.   dacmode(0,$8);
  1455. end;
  1456.  
  1457.   {Sets the standard palette mode}
  1458. procedure setDACstd;
  1459. begin
  1460.   case cv.dactype of
  1461.   _dac15,_dac16,_dacADAC1,_dacATT490,_dacATT491,_dacATT492,_dacATT493,
  1462.   _dacICS5301,_dacSC15021,_dacSC15025,_dacMU1880,_dacMU4870,_dacMU4910,
  1463.   _dacMU9910,_dacTR8001,_dacUMC188:
  1464.       dacmode(0,0);
  1465.   _dacALG1201,_dacALG1301:
  1466.       dacmode(0,2);
  1467.   _dacATT498,_dacATT1498,_dacATT2498,_dacICW498,_dacICW516:
  1468.       if dacpath=8 then dacmode(0,0) else dacmode(0,$20);
  1469.   _dacS3_708,_dacS3_716:
  1470.       clrreg(SetDACpage(dacHIcmd),$60);
  1471.   _dacSTG1700,_dacSTG1702,_dacSTG1703:
  1472.       if (inp(SetDACpage(dacHIcmd)) and 8)=0 then dacmode(0,0)
  1473.                                              else setSTGdac(5);
  1474.   _dacBt481,_dacBt482:
  1475.       setBt1DAC(0);
  1476.   _dacBt484,_dacBt485,_dacATT504,_dacATT505:
  1477.       begin
  1478.         modreg(SetDACpage(dacBTcmd1),$78,$40);
  1479.         {clrreg(SetDACpage(dacBTcmd2),$20);}
  1480.       end;
  1481.   _dacCH8391,_dacCH8398:
  1482.       dacmode(0,4);
  1483.   _dacTVP3010,_dacTVP3020,_dacTVP3025:
  1484.       begin
  1485.         wrDACreg(dacTVPindex,$18);
  1486.         wrDACreg(dacTVPdata,$C6);
  1487.         wrDACreg(dacTVPindex,$E);
  1488.         setDACreg(dacTVPdata,1);
  1489.       end;
  1490.   _dacTVP3026:
  1491.       begin
  1492.         wrDACreg(dacTVP6index,$18);
  1493.         wrDACreg(dacTVP6data,$C6);
  1494.         wrDACreg(dacTVP6index,$E);
  1495.         setDACreg(dacTVP6data,1);
  1496.       end;
  1497.   _dacATI68860,_dacATI68880:
  1498.       outp(setDACpage(11),$83);
  1499.   _dacInt:
  1500.       case cv.chip of
  1501.       __chips:clrinx(cv.IOadr,6,$C);
  1502.       __Cir54:dacmode(0,0);
  1503.          __WD:clrinx(SEQ,$26,$C);
  1504.          __S3:begin
  1505.                 outpw(crtc,$A039);
  1506.                 clrinx(crtc,$67,$F0);
  1507.                 outpw(crtc,$39);
  1508.               end;
  1509.         __SiS:clrinx(SEQ,6,$1C);
  1510.        __Trid:dacmode(0,0);
  1511.       end;
  1512.   _dacALG1101:
  1513.       clrinx(crtc,$19,$10);
  1514.  
  1515.     _dac0,_dac8,_dacCEG:;   {not supported/NOP}
  1516.   end;
  1517.   clearDACpage;
  1518. end;
  1519.  
  1520.   {Enable DAC Gamma correction}
  1521. function setDACgamma(on:boolean):word;
  1522. var x:word;
  1523. begin
  1524.   setDACgamma:=GAM_None;
  1525.   case cv.dactype of
  1526.     _dacBt484,_dacBt485,_dacATT504,_dacATT505:
  1527.         begin
  1528.           setDACreg(6,2);   {Enable 8bit LUT}
  1529.           setDACreg(9,4);   {Contigous Gamma curve}
  1530.           modDACreg(8,$10,$10*ord(not on));
  1531.           setDACgamma:=GAM_CanDo+GAM_8bit;
  1532.         end;
  1533.     _dacSC15021,_dacSC15025:
  1534.         begin
  1535.           dac2comm;
  1536.           x:=inp($3C6);
  1537.           outp($3C6,x or $10); {Index}
  1538.           outp($3C7,8);
  1539.           outp($3C8,1);    {8bit LUT}
  1540.           outp($3C6,(x and $F7) or 8*ord(on));   {Gamma}
  1541.           dac2pel;
  1542.           setDACgamma:=GAM_CanDo+GAM_LeftJ+GAM_Left8+GAM_8bit;
  1543.         end;
  1544.   end;
  1545. end;
  1546.  
  1547.   {Turns 8bit DAC mode on or off}
  1548. procedure setdac8(on:boolean);
  1549. var w,x:word;
  1550. begin
  1551.   if cv.chip=__VESA then
  1552.   begin
  1553.     if on then rp.bx:=$800
  1554.       else rp.bx:=$600;
  1555.     vio($4F08);
  1556.   end
  1557.   else
  1558.     case cv.dactype of
  1559.     _dacALG1201,_dacALG1301:
  1560.         dacmode(2,128*ord(on));
  1561.     _dacATI68860,_dacATI68880:
  1562.         modreg(setDACpage(12),1,1-ord(on));
  1563.     _dacATT490,_dacATT491,_dacATT492,_dacATT493,_dacATT498,_dacATT1498,
  1564.     _dacATT2498,_dacICW498,_dacICW516,_dacSTG1700,_dacSTG1702,_dacSTG1703,
  1565.     _dacCH8391,_dacTr8001:
  1566.         dacmode($FD,2*ord(on));   {2:on, 0: off}
  1567.     _dacBt477,_dacBt484,_dacBt485,_dacATT504,_dacATT505:
  1568.         modreg(setDACpage(dacBTcmd0),2,2*ord(on));
  1569.     _dacBt481,_dacBt482:
  1570.         begin
  1571.           setreg(setDACpage(dacHIcmd),1);  {Indexed}
  1572.           outp(setDACpage(dacSTDwrInx),dacBtIcmdB);
  1573.           modreg(setDACpage(dacSTDpelMask),2,2*ord(on));
  1574.           clrreg(setDACpage(dacHIcmd),1);  {Normal}
  1575.         end;
  1576.     _dacIBM514,_dacIBM524,_dacIBM525,_dacIBM528:
  1577.         begin
  1578.         (*  wrDACreg(dacIBMind0,$71);
  1579.          { wrDACreg(dacIBMind1,0);}
  1580.           modDACreg(dacIBMdata,4,4*ord(on)); * )
  1581.           wrDACreg(dacIBMind0,$71);
  1582.           x:=rdDACreg(dacIBMdata);
  1583.           wrDACreg(dacIBMind0,$71);
  1584.           wrDACreg(dacIBMdata,(x and $FB) or 4*ord(on)); *)
  1585.         end;
  1586.     _dacSC15021,_dacSC15025:
  1587.         begin
  1588.           dac2comm;
  1589.           outp($3C6,$10);
  1590.           outp($3C7,8);
  1591.           outp($3C8,ord(on)); {1: on, 0: off}
  1592.         {outp($3C9,0);  }
  1593.           outp($3C6,0);
  1594.           dac2pel;
  1595.         end;
  1596.     _dacTVP3010,_dacTVP3020,_dacTVP3025:
  1597.         begin
  1598.           wrDACreg(dacTVPindex,$1E);
  1599.           modDACreg(dacTVPdata,$C,8*ord(on)+4);
  1600.         end;
  1601.     _dacTVP3026:
  1602.         begin
  1603.           wrDACreg(dacTVP6index,$1E);
  1604.           modDACreg(dacTVP6data,$C,8*ord(on)+4);
  1605.         end;
  1606.     else
  1607.       case cv.chip of
  1608.      __Mach64:modreg($62ED,1,ord(on));
  1609.      __Mach32,
  1610.     __ati:begin
  1611.         w:=inpw($8EEE) and $BFFF;
  1612.         if on then w:=w or $4000;
  1613.         outpw($7AEE,w);
  1614.           end;
  1615.        __Trid:if cv.version>=TR_9200CXr{=TR_GUI9440} then
  1616.                 dacmode($FD,2*ord(on));   {2:on, 0: off}
  1617.                    {dacmode($F7,8*ord(on));   {2:on, 0: off}
  1618.      __Video7:begin  {Don't know if this works yet}
  1619.                 setinx(SEQ,$C1,1);
  1620.                 outp($46E8,$16);
  1621.                 inline($EE);
  1622.                 outp(SEQ,$D0);
  1623.                 modinx(SEQ,$B,3,ord(on)*2+1);
  1624.                 outp($46E8,$E);
  1625.                 inline($EE);
  1626.               end;
  1627.       end;
  1628.     end;
  1629.   clearDACpage;
  1630. end;
  1631.  
  1632. function setdac15:boolean;
  1633. var m:word;
  1634. begin
  1635.   setdac15:=true;
  1636.   GetDACpath;
  1637.   case cv.dactype of
  1638.   _dacALG1201,_dacALG1301:
  1639.       dacmode(0,$A2);
  1640.   _dac15,_dac16,_dacATT490,_dacATT491,_dacATT492,_dacATT493,_dacICS5301,
  1641.   _dacSC15021,_dacSC15025,_dacMU1880,_dacMU4910,_dacMU9910,_dacUMC188,
  1642.   _dacCH8391,_dacTR8001:
  1643.       dacmode(0,$A0);
  1644.   _dacADAC1:dacmode($38,$C1);
  1645.   _dacATT498,_dacATT1498,_dacATT2498,_dacICW498,_dacICW516:
  1646.       if dacpath=8 then dacmode(0,$A0) else dacmode(0,$10);
  1647.   _dacS3_708,_dacS3_716:
  1648.       begin
  1649.         if (inp(SetDACpage(dacHIcmd)) and $10)>0 then m:=$30
  1650.                                                  else m:=$20;
  1651.         modreg(SetDACpage(dacHIcmd),$F0,m);
  1652.       end;
  1653.   _dacSTG1700,_dacSTG1702,_dacSTG1703:
  1654.       if (inp(SetDACpage(dacHIcmd)) and 8)=0 then dacmode(0,$A0)
  1655.                                              else setSTGdac(2);
  1656.   _dacBt481,_dacBt482:
  1657.       setBt1DAC($A0);
  1658.   _dacBt484,_dacBt485,_dacATT504,_dacATT505:
  1659.       modreg(SetDACpage(dacBTcmd1),$78,$30);
  1660.   _dacCH8398:
  1661.       if dacpath=8 then dacmode(0,$C4) else dacmode(0,$14);
  1662.   _dacTVP3010,_dacTVP3020,_dacTVP3025:
  1663.       begin
  1664.         wrDACreg(dacTVPindex,$18);
  1665.         modDACreg(dacTVPdata,$CF,$C);
  1666.         wrDACreg(dacTVPindex,$E);
  1667.         clrDACreg(dacTVPdata,1);
  1668.       end;
  1669.   _dacTVP3026:
  1670.       begin
  1671.         wrDACreg(dacTVP6index,$18);
  1672.         modDACreg(dacTVP6data,$CF,$C);
  1673.         wrDACreg(dacTVP6index,$E);
  1674.         clrDACreg(dacTVP6data,1);
  1675.       end;
  1676.   _dacATI68860,_dacATI68880:
  1677.       outp(setDACpage(11),$A0);
  1678.   _dacInt:case cv.chip of
  1679.           __chips:modinx(cv.IOadr,6,$C,4);
  1680.           __Cir54:dacmode(0,$A0);
  1681.              __WD:modinx(SEQ,$26,$C,$C);
  1682.              __S3:begin
  1683.                     outpw(crtc,$A039);
  1684.                     modinx(crtc,$67,$F0,$30);
  1685.                     outpw(crtc,$39);
  1686.                   end;
  1687.             __SiS:modinx(SEQ,6,$1C,4);
  1688.            __Trid:if cv.version=TR_GUI9440 then dacmode(0,$10)
  1689.                                            else dacmode(0,$A0);
  1690.           end;
  1691.  
  1692.     _dac0,_dac8,_dacCEG,_dacALG1101:
  1693.         setdac15:=false;
  1694.   end;
  1695.   clearDACpage;
  1696. end;
  1697.  
  1698. function setdac16:boolean;
  1699. var m:word;
  1700. begin
  1701.   GetDACpath;
  1702.   setdac16:=true;
  1703.   case cv.dactype of
  1704.   _dac16,_dacUMC188,_dacTR8001,_dacSC15021,_dacSC15025:
  1705.       dacmode(0,$E0);
  1706.   _dacADAC1:
  1707.       dacmode($38,$C5);
  1708.   _dacALG1201,_dacALG1301:
  1709.       dacmode(0,$C2);
  1710.   _dacATI68860,_dacATI68880:
  1711.       outp(setDACpage(11),$A1);
  1712.   _dacCH8391,
  1713.   _dacATT490,_dacATT491,_dacATT492,_dacATT493,_dacICS5301,_dacMU4910,_dacMU9910:
  1714.       dacmode(0,$C0);
  1715.   _dacATT498,_dacATT1498,_dacATT2498:
  1716.       if dacpath=8 then dacmode(0,$60) else dacmode(0,$30);
  1717.   _dacBt481,_dacBt482:
  1718.       setBt1DAC($E0);
  1719.   _dacBt484,_dacBt485,_dacATT504,_dacATT505:
  1720.       modreg(SetDACpage(dacBTcmd1),$78,$38);
  1721.   _dacCH8398:
  1722.       if dacpath=8 then dacmode(0,$64) else dacmode(0,$34);
  1723.   _dacMU1880:
  1724.       dacmode(0,$A6);
  1725.   _dacS3_708,_dacS3_716:
  1726.       begin
  1727.         if (inp(SetDACpage(dacHIcmd)) and $10)>0 then m:=$50
  1728.                                                  else m:=$60;
  1729.         modreg(SetDACpage(dacHIcmd),$F0,m);
  1730.       end;
  1731.   _dacSTG1700,_dacSTG1702,_dacSTG1703:
  1732.       if (inp(SetDACpage(dacHIcmd)) and 8)=0 then dacmode(0,$C0)
  1733.                                              else setSTGdac(3);
  1734.   _dacTVP3010,_dacTVP3020,_dacTVP3025:
  1735.       begin
  1736.         wrDACreg(dacTVPindex,$18);
  1737.         modDACreg(dacTVPdata,$CF,$D);
  1738.         wrDACreg(dacTVPindex,$E);
  1739.         clrDACreg(dacTVPdata,1);
  1740.       end;
  1741.   _dacTVP3026:
  1742.       begin
  1743.         wrDACreg(dacTVP6index,$18);
  1744.         modDACreg(dacTVP6data,$CF,$D);
  1745.         wrDACreg(dacTVP6index,$E);
  1746.         clrDACreg(dacTVP6data,1);
  1747.       end;
  1748.   _dacInt:case cv.chip of
  1749.           __chips:modinx(cv.IOadr,6,$C,$C);
  1750.           __Cir54:dacmode(0,$E1);
  1751.              __WD:modinx(SEQ,$26,$C,4);
  1752.              __S3:begin
  1753.                     outpw(crtc,$A039);
  1754.                     modinx(crtc,$67,$F0,$50);
  1755.                     outpw(crtc,$39);
  1756.                   end;
  1757.             __SiS:modinx(SEQ,6,$1C,8);
  1758.            __Trid:if cv.version=TR_GUI9440 then dacmode(0,$30)
  1759.                                            else dacmode(0,$E0);
  1760.           else setdac16:=false;
  1761.           end;
  1762.   _dacALG1101:;  {Unknown}
  1763.  
  1764.     _dac0,_dac8,_dacCEG,_dac15:
  1765.         setdac16:=false;
  1766.   end;
  1767.   clearDACpage;
  1768. end;
  1769.  
  1770. function setdac24:boolean;
  1771. var m:word;
  1772. begin
  1773.   GetDACpath;
  1774.   setdac24:=true;
  1775.   case cv.dactype of
  1776.   _dacADAC1:
  1777.       dacmode($38,$80);
  1778.   _dacALG1201,_dacALG1301:
  1779.       dacmode(0,$E2);
  1780.   _dacATI68860,_dacATI68880:
  1781.       outp(setDACpage(11),$C0);
  1782.   _dacCH8391,
  1783.   _dacATT490,_dacATT491,_dacATT492,_dacATT493,_dacICS5301,_dacMU4910,_dacMU9910:
  1784.       dacmode(0,$E0);
  1785.   _dacATT498,_dacATT1498,_dacATT2498,_dacICW498,_dacICW516:
  1786.       dacmode(0,$50);
  1787.   _dacBt481,_dacBt482:
  1788.       setBt1DAC($F0);
  1789.   _dacBt484,_dacBt485,_dacATT504,_dacATT505:
  1790.       modreg(SetDACpage(dacBTcmd1),$78,$10);
  1791.   _dacCH8398:
  1792.       if dacpath=8 then dacmode(0,$74) else dacmode(0,$B4);
  1793.   _dacMU1880:
  1794.       dacmode(0,$9E);
  1795.   _dacSC15021,_dacSC15025:
  1796.       dacmode(0,$60);
  1797.   _dacS3_708,_dacS3_716:
  1798.       begin
  1799.         if (inp(SetDACpage(dacHIcmd)) and $10)>0 then m:=$70
  1800.                                                  else m:=$E0;
  1801.         modreg(SetDACpage(dacHIcmd),$F0,m);
  1802.       end;
  1803.   _dacSTG1700:
  1804.       if (inp(SetDACpage(dacHIcmd)) and 8)=0 then dacmode(0,$E0);
  1805.   _dacSTG1702,_dacSTG1703:
  1806.       if (inp(SetDACpage(dacHIcmd)) and 8)=0 then dacmode(0,$E0)
  1807.                                              else setSTGdac(9);   {1702/3 only!}
  1808.   _dacTR8001:
  1809.       dacmode(0,$C2);
  1810.   _dacUMC188:
  1811.       dacmode(0,$F0);
  1812.   _dacInt:case cv.chip of
  1813.           __chips:if (cv.chip=__chips) and (cv.Version=CT_64300) then
  1814.                     modinx(cv.IOadr,6,$C,8);
  1815.           __Cir54:begin
  1816.                     dacmode(0,$E5);
  1817.                     modinx(SEQ,7,$E,4);
  1818.                   end;
  1819.              __S3:begin
  1820.                     outpw(crtc,$A039);
  1821.                     modinx(crtc,$67,$F0,$D0);
  1822.                     outpw(crtc,$39);
  1823.                   end;
  1824.             __SiS:modinx(SEQ,6,$1C,$10);
  1825.            __Trid:if cv.version=TR_GUI9440 then dacmode(0,$D0)
  1826.                                            else dacmode(0,$C2);
  1827.           else setdac24:=false;
  1828.           end;
  1829.     _dacBt477,
  1830.     _dacALG1101,_dac0,_dac8,_dacCEG,_dac15,_dac16:setdac24:=false;
  1831.   else setdac24:=false;
  1832.   end;
  1833.   clearDACpage;
  1834. end;
  1835.  
  1836. function setdac32:boolean;
  1837. var m:word;
  1838. begin
  1839.   setdac32:=true;
  1840.   case cv.dactype of
  1841.   _dacATI68860,_dacATI68880:
  1842.       outp(setDACpage(11),$E3);
  1843.   _dacATT498,_dacATT1498,_dacATT2498,_dacICW498,_dacICW516:
  1844.       dacmode(0,$50);
  1845.   _dacBt484,_dacBt485,_dacATT504,_dacATT505:
  1846.       modreg(SetDACpage(dacBTcmd1),$78,$10);
  1847.  
  1848.   _dacS3_708,_dacS3_716:
  1849.       modreg(SetDACpage(dacHIcmd),$F0,$70);
  1850.   _dacSC15021,_dacSC15025:
  1851.       dacmode(0,$40);
  1852.   _dacSTG1700,_dacSTG1702,_dacSTG1703:
  1853.       if (inp(SetDACpage(dacHIcmd)) and 8)>0 then setSTGdac(4);
  1854.   _dacTR8001:
  1855.       dacmode(0,$C4);
  1856.  
  1857.   _dacInt:case cv.chip of
  1858.           __Cir54:begin
  1859.                     dacmode(0,$E5);
  1860.                     modinx(SEQ,7,$E,8);
  1861.                   end;
  1862.           end;
  1863.  
  1864.  
  1865.   (*   _dacMus,
  1866.   _dacATT:dacmode(0,$E0);
  1867.     _dacATT2:dacmode(0,$50);
  1868.     _dacSC24:dacmode(0,$60);
  1869.     _dacCL24:begin
  1870.                dacmode(0,$E5);
  1871.                setinx(SEQ,7,8);
  1872.              end;
  1873.       _dacS3:begin
  1874.                if (inp(SetDACpage(dacHIcmd)) and $10)>0 then m:=$70
  1875.                                                         else m:=$E0;
  1876.                modreg(SetDACpage(dacHIcmd),$F0,m);
  1877.              end;
  1878.    _dacCHRON:dacmode(0,$74); {or $54/$B4 for 16bit/clk?}
  1879.     _dacTVP:begin
  1880.               modinx(setDACpage(dacTVPindex),$18,$CF,$E);
  1881.               clrinx(setDACpage(dacTVPindex),$E,$1);
  1882.             end;
  1883.      _dacInt:case cv.chip of
  1884.              __chips:if (cv.chip=__chips) and (cv.Version=CT_64300) then
  1885.                        modinx(cv.IOadr,6,$C,8);
  1886.                 __S3:begin
  1887.                        outpw(crtc,$A039);
  1888.                        modinx(crtc,$67,$F0,$D0);
  1889.                        outpw(crtc,$39);
  1890.                      end;
  1891.              else setdac32:=false;
  1892.              end; *)
  1893.     _dacBt477,
  1894.     _dacALG1101,_dac0,_dac8,_dacCEG,_dac15,_dac16:setdac32:=false;
  1895.   else setdac32:=false;
  1896.   end;
  1897.   clearDACpage;
  1898. end;
  1899.  
  1900.  
  1901.   {Returns the pixel BIT address}
  1902. function pixeladdress(x,y:word):longint;
  1903. begin
  1904.   case memmode of
  1905. _pk4,_pk4a,_pk4b:pixeladdress:=(bytes*y*2+x) shl 2;
  1906.              _p8:pixeladdress:=(bytes*y+x) shl 3;
  1907.        _p15,_p16:pixeladdress:=(bytes*y+x*2) shl 3;
  1908.       _p24,_p24b:pixeladdress:=(bytes*y+x*3) shl 3;
  1909.      _p32.._p32d:pixeladdress:=(bytes*y+x*4) shl 3;
  1910.   end;
  1911. end;
  1912.  
  1913.  
  1914. procedure setvstart(x,y:word);       {Set the display start address}
  1915. var
  1916.   adr:record       {The linear start address (l) is overlayed with
  1917.             the individual bytes (pel, displ,disph and bank)}
  1918.     case byte of
  1919.       0:(l:longint);
  1920.       1:(pel:byte;disp:word;bank:byte);
  1921.       end;
  1922.   stdvga:boolean;
  1923.   shft:word;
  1924. begin
  1925.  
  1926.   stdvga:=(cv.flags and FLG_StdVGA)>0; {default, can be disabled}
  1927.   shft:=5;
  1928.  
  1929.   case cv.chip of
  1930.     __vesa:begin
  1931.            rp.bx:=0;
  1932.            rp.cx:=x;
  1933.            rp.dx:=y;
  1934.            vio($4F07);
  1935.            if rp.ax=0 then;
  1936.            stdvga:=false;
  1937.          end;
  1938.   else
  1939.     case memmode of
  1940.     _text,_txt2,_txt4:
  1941.           adr.l:=(bytes*y+x*2)*2;
  1942.         _cga2:adr.l:=(bytes*y+(x shr 2))*4;
  1943.   _cga1,_pl1,_pl2,_pl4:
  1944.           adr.l:=(bytes*y*8+x) shl 5;
  1945.  _pk4,_pk4a,_pk4b:adr.l:=(bytes*y*2+x) shl 5;
  1946.           _p8:adr.l:=(bytes*y+x) shl 6;
  1947.     _p15,_p16:adr.l:=(bytes*y+x*2) shl 6;
  1948.        _p24,_p24b:adr.l:=(bytes*y+x*3) shl 6;
  1949.       _p32.._p32d:adr.l:=(bytes*y+x*4) shl 6;
  1950.     end;
  1951.     case cv.chip of
  1952.         __Acer:modinx(crtc,$81,$30,adr.bank shl 4);
  1953.        __ahead:begin    {Maybe this is only for the B??}
  1954.          if (memmode=_p8) and ((rdinx(GRC,$C) and $20)>0) then
  1955.            adr.l:=adr.l shr 1;
  1956.          modinx(GRC,$1C,3,adr.bank);
  1957.            end;
  1958.         __Alli:modinx(crtc,$1C,$F,adr.bank);
  1959.          __ARK:begin
  1960.                  if (rdinx(crtc,$46) and 4)>0 then adr.l:=adr.l shr 1;
  1961.                  modinx(crtc,$40,7,adr.bank);
  1962.                end;
  1963.      __ati:begin
  1964.                  if ((cv.version=ATI_18800_1) and ((rdinx(cv.IOadr,$B3)
  1965.                    and $40)>0)) or ((cv.version>=ATI_18800_1)
  1966.                    and ((rdinx(cv.IOadr,$B0) and $20)>0)) then adr.l:=adr.l shr 1;
  1967.          modinx(cv.IOadr,$B0,$40,adr.bank shl 6);  {DSA bit 16}
  1968.          if (cv.version>ATI_18800_1) then
  1969.            modinx(cv.IOadr,$A3,$10,adr.bank shl 3);  {DSA bit 17}
  1970.          if cv.version>=ATI_GUP_3 then
  1971.            modinx(cv.IOadr,$AD,$C,adr.bank);
  1972.                  if (cv.Version>=ATI_M64_GX) and (memmode<_P8) then shft:=6;
  1973.            end;
  1974.      __ALG:begin
  1975.          if (rdinx(GRC,$C) and $10)<>0 then adr.l:=adr.l shr 1;
  1976.          modinx(crtc,$20,7,adr.bank);
  1977.            end;
  1978.        __chips:begin
  1979.                  wrinx(cv.IOadr,$C,adr.bank);
  1980.                  if (rdinx(cv.IOadr,$28) and $10)>0 then shft:=6;
  1981.                end;
  1982.        __cir54:begin
  1983.          inc(adr.bank,adr.bank and 6);     {move bit 1-2 to 2-3}
  1984.          modinx(crtc,$1B,$D,adr.bank);
  1985.          if (rdinx(SEQ,7) and 1)>0 then inc(shft);
  1986.          if (rdinx(SEQ,7) and 6)=6 then inc(shft);
  1987.            end;
  1988.        __cir64:wrinx(GRC,$7C,adr.bank);
  1989.       __compaq:begin
  1990.                  modinx(GRC,$42,$1C,adr.bank shl 2);
  1991.                  if (memmode=_P8) and (curmode<>$13) then shft:=6;
  1992.                end;
  1993.      __HMC:begin
  1994.          if (rdinx(SEQ,$E7) and 1)>0 then adr.l:=adr.l shr 1;
  1995.          modinx(SEQ,$ED,1,adr.bank);
  1996.            end;
  1997.      __AGX:begin
  1998.          stdvga:=false;
  1999.          wrinx3(cv.IOadr+10,$40,adr.l shr 8);
  2000.            end;
  2001.       __Mach32:begin
  2002.                  outpw($2AEE,adr.disp);
  2003.                  outpw($2EEE,adr.bank);
  2004.                  stdvga:=false;
  2005.                end;
  2006.       __Mach64:begin
  2007.                  meml[cv.Xseg:$14]:=(meml[cv.Xseg:$14] and $FFF00000)
  2008.                                   or (adr.l shr 9);
  2009.                  stdvga:=false;
  2010.                end;
  2011.       __Matrox:begin
  2012.                  if memmode=_p8 then
  2013.                  begin
  2014.                    adr.l:=adr.l shr 1;
  2015.                    clrinx(crtc,$11,$80);
  2016.                    modinx(crtc,8,$60,adr.disp shl 5);
  2017.                  end;
  2018.                  modinx($3DE,$A,$13,adr.bank+$10);
  2019.                end;
  2020.     __mxic:begin
  2021.          modinx(SEQ,$F1,3,adr.bank);
  2022.          if (memmode>=_p8) and (curmode<>$13) then inc(shft);
  2023.            end;
  2024.      __ncr:modinx(crtc,$31,$F,adr.bank);
  2025.      __oak:if cv.Version<=OAK_083 then
  2026.                begin
  2027.          if (memmode>_pl4) and (curmode<>$13) then adr.l:=adr.l shr 1;
  2028.          modinx($3DE,$14,8,adr.bank shl 3);  {lower bit}
  2029.          modinx($3DE,$16,8,adr.bank shl 2);  {upper bit}
  2030.            end
  2031.                else begin
  2032.          if (memmode>_pl4) and ((rdinx($3DE,$21) and 4)>0) then
  2033.            adr.l:=adr.l shr 1;
  2034.          modinx($3DE,$17,7,adr.bank);
  2035.            end;
  2036.        __p2000:begin
  2037.          modinx(GRC,$21,$7,adr.bank);
  2038.          if memmode>=_P8 then inc(shft);
  2039.            end;
  2040.           __WD:begin
  2041.          modinx(GRC,$D,$18,adr.bank shl 3);
  2042.          if cv.version=WD_90c33 then
  2043.          begin
  2044.            x:=rdinx(crtc,$11);
  2045.            clrinx(crtc,$11,$80);  {Must unlock}
  2046.            modinx(crtc,$3E,$40,adr.bank shl 4);
  2047.            wrinx(crtc,$11,x);
  2048.          end;
  2049.            end;
  2050.      __realtek:begin
  2051.          if (rdinx(GRC,$C) and $10)<>0 then adr.l:=adr.l shr 1;
  2052.          inc(adr.bank,adr.bank and 2);   {shift high bit one up.}
  2053.          modinx(crtc,$19,$50,adr.bank shl 4);
  2054.            end;
  2055.       __s3:begin
  2056.          wrinx(crtc,$38,$48);
  2057.          modinx(crtc,$31,$30,adr.bank shl 4);
  2058.                  if cv.version>S3_924 then
  2059.                  begin
  2060.                    wrinx(crtc,$39,$A5);
  2061.                    modinx(crtc,$51,3,adr.bank shr 2);
  2062.                    wrinx(crtc,$39,$5A);
  2063.                  end;
  2064.          wrinx(crtc,$38,0);
  2065.            end;
  2066.           __SC:modinx(crtc,$1E,$F,adr.bank);
  2067.          __SiS:modinx(SEQ,$27,$F,adr.bank);
  2068.     __trid:begin
  2069.          if cv.version>TR_8800CS then
  2070.          begin
  2071.            wrinx(SEQ,$B,0);          {select old mode regs}
  2072.            if (rdinx(SEQ,$D) and $10)>0 then adr.l:=adr.l shr 1;
  2073.              if (cv.Version=TR_8900B) or (cv.Version=TR_8900C) then
  2074.              modinx(SEQ,$E,1,adr.bank shr 1);
  2075.            if rdinx(SEQ,$B)=0 then;  {Select new mode regs}
  2076.          end;
  2077.          modinx(crtc,$1E,$20,adr.bank shl 5);
  2078.                  if cv.Version>=TR_9000C then
  2079.                    modinx(crtc,$27,3,adr.bank shr 1);
  2080.                  if (cv.version>=TR_8900CL) and ((rdinx(GRC,$F) and 2)>0) then shft:=6;
  2081.            end;
  2082.        __Tseng:if cv.version=ET_3000 then
  2083.            begin
  2084.          if (memmode=_p8) or ((rdinx(SEQ,7) and $40)>0) then
  2085.          begin
  2086.            adr.l:=adr.l shr 1;
  2087.            inc(shft);
  2088.          end;
  2089.          modinx(crtc,$23,2,adr.bank shl 1);
  2090.            end
  2091.            else begin
  2092.          if cv.version=ET_4000 then x:=3 else x:=$F;
  2093.          modinx(crtc,$33,x,adr.bank);
  2094.          if (memmode>=_p8) and (curmode<>$13) then inc(shft);
  2095.            end;
  2096.      __UMC:begin
  2097.         if (rgs.crtcregs.x[$33] and $10)>0 then adr.l:=adr.l shr 1;
  2098.         modinx(crtc,$33,3,adr.bank);
  2099.            end;
  2100.       __video7:begin
  2101.                  modinx(SEQ,$F6,$30,adr.bank shl 4);
  2102.                  if (rdinx(SEQ,$C8) and $10)>0 then shft:=6;
  2103.                end;
  2104.      { __Weitek:begin   This doesn't work!!
  2105.                  modinx(SEQ,5,$84,$80+(adr.bank shl 2));
  2106.                  wrinx(crtc,$1A,hi(adr.disp));
  2107.                  wrinx(crtc,$1B,lo(adr.disp));
  2108.                  stdvga:=false;
  2109.                end; }
  2110.    __xbe,__xga:begin
  2111.          stdvga:=false;
  2112.          wrinx3(cv.IOadr+10,$40,adr.l shr 8);
  2113.            end;
  2114.     end;
  2115.   end;
  2116.   if stdvga then
  2117.   begin
  2118.     clrinx(crtc,$11,$80);
  2119.     wrinx($3C0,$13,adr.pel shr shft);
  2120.     outp($3C0,$33);
  2121.     wrinx(crtc,$D,lo(adr.disp));
  2122.     wrinx(crtc,$C,hi(adr.disp));
  2123.   end;
  2124. end;
  2125.  
  2126. begin
  2127. end.
  2128.